Images can be compressed by JPEG2000 (J2K) compression and videos can be compressed by Motion JPEG2000 compression, which are referred to as JPEG2000-based compression. A J2K codestream is organized in a hierarchical structure and provides Fine Granularity Scalability (FGS) that can be truncated to the preset layers (i.e., qualities), resolutions, components, tiles, etc., or to coding passes inside a packet to fit a large variety of application scenarios. Motion JPEG 2000 encodes each video frame independently using a J2K codestream.
FIG. 1 is a block diagram that illustrates divisions of an image according to JPEG2000. An image is divided into one “component” 101 for each color. For example, if the image is an RGB image, then it has a red component, a green component, and a blue component. Each component is divided into “tiles” 102 that each represent an area of the component. For example, a component may be divided into four equally sized tiles as shown in FIG. 1: upper left, upper right, lower left, and lower right portions of the component. Each tile is compressed separately. To compress a tile, it is decomposed using a discrete wavelet transform into four subbands 103: a low-low (“LL”) subband, a low-high (“LH”) subband, a high-low (“HL”) subband, and a high-high (“HH”) subband. The LL subband represents a low pass transformation of the image in both the horizontal and vertical directions, the LH subband represents a low pass transformation of the image in the horizontal direction and a high pass transformation of the image in the vertical direction, and similarly for the HL and HH subbands. After the tile is decomposed, the LL subband can then be further decomposed using a discrete wavelet transform into four subbands. The LL subband of the LL subband is again decomposed into four subbands. The decomposing of the LL subband continues for a number of resolution levels 104. The final LL subband is referred to as the resolution level 0 subband. It is also the image at resolution 0. The image at resolution 1 consists of the image at resolution 0 plus the subbands of resolution 1. More generally, the image at resolution r (when r>0) consists of the image of resolution r−1 and the subbands at resolution level r. When the compression is lossy, the wavelet coefficients are quantized.
FIG. 2 is a diagram that illustrates divisions of a decomposed image that are used for encoding. To encode the decomposed image, each subband of a tile 201 is divided into non-overlapping rectangular blocks, referred to as “code-blocks” 202. Each code-block is independently arithmetically encoded from the most significant bitplane to the least significant bitplane. Each bitplane is encoded using an embedded block coding with an optimized truncation (“EBCOT”) technique with three passes: a significant propagation pass, a magnitude refinement pass, and a cleanup pass. The arithmetic encoding is terminated at the end of the last bitplane, and the encoded bitstream forms an arithmetic codeword segment (“ACS”). JPEG2000 also allows termination at the end of each coding pass such that each coding pass generates an ACS. The context data for the EBCOT technique can be initialized at the end of each sub-bitplane coding pass to allow independent decoding of the bitstream from each coding pass. JPEG2000 has an optional coding bypass that inserts raw data into the bitstream for certain coding passes resulting in a raw coding segment (“RCS”). The boundaries between arithmetic coding passes and raw passes are terminated.
JPEG2000 specifies that a code-block's bitstream is distributed across one or more layers in a codestream. A layer consists of a number of consecutive bit-plane coding passes from each code-block in a tile including all subbands of all components for that tile. JPEG2000 defines an intermediate space-frequency structure known as a “precinct” 203. A precinct is a group of spatially contiguous code-blocks from the LH, HL, and HH subbands of a resolution level.
A JPEG2000 codestream consists of “packets.” Each packet is a continuous segment in the compressed codestream representing a component, specific tile, layer, resolution level, and precinct. Each packet can be uniquely identified by tile, component, resolution level, layer, and precinct. JPEG2000 allows for various coding progression orders for a tile based on component, resolution level, layer, and precinct.
A packet header contains the data length of each Code-block Contribution to the Packet (“CCP”). JPEG2000 does not allow within an ACS or a CCP a byte-aligned value between 0xFF90 and 0xFFFF for any two consecutive bytes or ending with a byte value of 0xFF. A RCS does not allow any byte-aligned nine consecutive bits of 1 or ending with a byte of value 0xFF. JPEG2000 uses the unattainable range of two consecutive bytes to represent unique markers to facilitate organization and parsing of the bitstream and to improve error resilience.
Encryption can be applied to J2K codestreams to protect images from unauthorized access or usage. An important requirement for encryption of scalable codestreams is that the encrypted codestream should preserve as fine as possible granularity for scalability so that it can be truncated directly by an encryption-unaware device without decryption. In other words, as an image is processed by intermediaries, it is desirable that those intermediaries can reduce scale (e.g., resolution) of the image without having to decrypt the image. A desirable requirement for JPEG2000 encryption is that an encrypted J2K codestream is still compliant to JPEG2000 syntax and that encrypted data does not emulate any JPEG2000 delimiters to avoid erroneous parsing or synchronization, especially under error-prone transmissions.